const conn = require('../conn/mysql')


exports.getUsers = async function () {
  return conn('SELECT * FROM user;')
}

exports.addUser = async function (values) {
  return conn("insert INTO user set name=?,password=?;", values).then(data => {
    if (data.affectedRows != 0) {
      data.success = true
      return data
    }
    return data
  })
}

exports.updateUser = async function (values) {
  return conn("UPDATE user SET name=?,password=? WHERE name=?;", values).then(data => {
    if (data.affectedRows != 0) {
      data.success = true
      return data
    }
    return data
  })
}
